package com.amat0urheu.service.impl;


import com.amat0urheu.dao.LogMapper;
import com.amat0urheu.pojo.CloudPojo.OpenStack;
import com.amat0urheu.pojo.ReturnRes;
import com.amat0urheu.pojo.SystemLog;
import com.amat0urheu.service.SystemLogService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class SystemLogServiceImpl implements SystemLogService {
    @Autowired
    LogMapper logMapper;
    @Override
    public ReturnRes getExperimentpage(int pageSize, int pageNum) {
        PageHelper.startPage(pageNum, pageSize);
        List<SystemLog> systemLogs = logMapper.getAllSystemlogs();

        if (systemLogs != null) {
            return new ReturnRes(true, new PageInfo<>(systemLogs), "查询成功");
        }
        return new ReturnRes(false, "查询失败");

    }

    @Override
    public ReturnRes removeSystemLog(Integer id) {

        Integer count = logMapper.removeSystemLog(id);

        if (count >0) {
            return new ReturnRes(true,  "删除成功");
        }
        return new ReturnRes(false, "删除失败");
    }

    @Override
    public ReturnRes removeAllSystemLog() {
        Integer count = logMapper.removeAllSystemLog();

        if (count >0) {
            return new ReturnRes(true,  "删除成功");
        }
        return new ReturnRes(false, "删除失败");

    }
}
